/*
 * Middleware
 * Copyright (C) 2010/11
 * Riccardo Pulvirenti, Giuseppe Ravidà, Andrea Tino
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses
 */

/*!
 * File: tqueue_proxy_factory.hpp
 */

#ifndef _TQUEUE_PROXY_FACTORY_HPP_
#define _TQUEUE_PROXY_FACTORY_HPP_

#include <iostream>
#include <string>

#include "tqueue_manager_proxy.hpp"
#include "worker.hpp"

//-----------------------------------------------------------------------------
// Class definitions
namespace middleware {
/*! \class TQueueProxyFactory
 * \brief Instantiating a WorkerDiscoveryProxy object.
 *
 * Manages instantiation of a TQueueManagerProxy object.
 */
class TQueueProxyFactory {
public:
	/*!
	 * Constructs factory. The only constructor available needs the pointer to
	 * the Worker on which call the equeueing method.
	 * \param ptrtoworker Pointer to Worker in which the queue of TaskDescriptor
	 * resides.
	 */
	TQueueProxyFactory(Worker* ptrtoworker);
	/*!
	 * Destroys factory. When factory encounters destructor, dynamic allocated
	 * memory for proxy is AUTOMATICALLY released; when a factory dies, its
	 * proxy is deleted. This happens also when factory is called to get
	 * a proxy more than one time.
	 */
	~TQueueProxyFactory();
	/*!
	 * Get Proxy: attention, a new instance is created via dynamic allocation.
	 * If a previous proxy was generated, it will be detroyed.
	 */
	TQueueManagerProxy* getProxy();
private:
	/*!
	 * Holds built proxy. If the factory is detroyed, then so is the proxy.
	 */
	TQueueManagerProxy* _proxy;
	/*!
	 * Ip address to use to configure proxy.
	 */
	Worker* _ptrto_worker;
}; /* WFQueueProxyFactory */
} /* middleware */

#endif
